package com.benmei.ntlive.common;

/**
 * Created by Peter on 2018/10/15.
 */
public enum CourseType {
    c_1v1(1, "1v1", "一对一课程"),
    c_1vn(2, "1vn", "一对多课程");

    private final int code;

    private final String name;

    private final String desc;


    CourseType(int code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }


    public static CourseType getByCode(int code) {
        CourseType result = null;
        for (CourseType courseType : CourseType.values()) {
            if (courseType.code == code) {
                result = courseType;
            }
        }
        return result;
    }

    public static CourseType getByName(String name) {
        CourseType result = null;
        for (CourseType courseType : CourseType.values()) {
            if (courseType.name.equals(name)) {
                result = courseType;
            }
        }
        return result;
    }

    public static boolean contains(int code) {
        boolean result = false;
        for (CourseType courseType : CourseType.values()) {
            if (courseType.code == code) {
                result = true;
                break;
            }
        }
        return result;
    }

    public static boolean contains(String name) {
        boolean result = false;
        for (CourseType courseType : CourseType.values()) {
            if (courseType.name.equals(name)) {
                result = true;
                break;
            }
        }
        return result;
    }
}
